package com.sixdog.regulate.service.impl;

import com.sixdog.regulate.bean.CmdResult;
import com.sixdog.regulate.cmdService.CmdUtils;
import com.sixdog.regulate.service.ApkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ApkServiceIdImpl implements ApkService {
    @Autowired
    private CmdUtils cmdUtils;

    //普通安装apk
    @Override
    public CmdResult installApk(String deviceSerial,String FilePath){
        StringBuilder command =  new StringBuilder().append("adb -s ").append(deviceSerial).append(" install ").append(FilePath);
        CmdResult cmdResult = cmdUtils.execute(command);
        return cmdResult;
    }
    //覆盖安装apk
    @Override
    public CmdResult installApkCover(String deviceSerial,String FilePath){
        StringBuilder command =  new StringBuilder().append("adb -s ").append(deviceSerial).append(" install -r ").append(FilePath);
        CmdResult cmdResult = cmdUtils.execute(command);
        return cmdResult;
    }
    //卸载app
    @Override
    public CmdResult uninstallApp(String deviceSerial,String packageName){
        StringBuilder command =  new StringBuilder().append("adb -s ").append(deviceSerial).append(" uninstall ").append(packageName);
        CmdResult cmdResult = cmdUtils.execute(command);
        return cmdResult;
    }



}
